--循坏更新数据

DECLARE @VIN nvarchar(50);

DECLARE vdn_cursor CURSOR FOR
SELECT VIN FROM MdmVehicleVdn WHERE (VDN='' or VDN is null) and IsDeleted=0;

OPEN vdn_cursor;

FETCH NEXT FROM vdn_cursor INTO @VIN;

WHILE @@FETCH_STATUS = 0
BEGIN
    DECLARE @VDN nvarchar(max);
    SET @VDN= (SELECT VDN FROM MdmVehicleVdnTemporary WHERE VIN = @VIN);
	if @VDN is not null
	begin
    UPDATE MdmVehicleVdn SET VDN = @VDN,ModifiedOn=GETUTCDATE() WHERE VIN = @VIN;
	end
    FETCH NEXT FROM vdn_cursor INTO @VIN;
END;

CLOSE vdn_cursor;
DEALLOCATE vdn_cursor;
